import pymysql

db = pymysql.connect(host='localhost',user='root',password='926979',port=3306,database='test')
cursor = db.cursor()
sql = "DELETE FROM EMPLOTEE WHERE AGE >'%d'"%(40)

try:
    cursor.execute(sql)
    db.commit()
except:
    db.rollback()

db.close()